package com.duan.learn.collection;

import java.util.Arrays;
import java.util.Vector;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class VectorTest {

    private static final int NEW_SIZE = 102;
    private static final int SIZE = 100;
    private static Vector<Integer> vector = new Vector<>(SIZE);

    static {
        for (int i = 0; i < SIZE; i++) {
            vector.add(i);
        }
    }

    public static void main(String[] args) throws Exception {
        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < SIZE; i++) {
                    vector.add(i);
                }
            }
        });

        Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = SIZE; i < SIZE*2; i++) {
                    vector.add(i);
                }
            }
        });

        thread1.start();
        thread2.start();
        Thread.sleep(1000);
        for(int i = 0; i < vector.size(); i++) {
            System.out.print(vector.get(i) + ", ");
        }

    }
}
